Skip to content

Conversation

katcharov
Copy link
Collaborator

JAVA-3879

Tracking PR.

This PR may be used to track anything that needs to be done prior to this expressions branch being merged into master.

Copy link
Member

@stIncMale stIncMale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @return left if true, right if false.
* @param <T> The type of the resulting expression.
*/
<T extends Expression> T cond(T left, T right);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one.eq(of(2)).cond(of("yes"), of("no"));

The present variant of cond does not supply the original value to the left and right branches. Above, the value is one, but it could be a long composite expression. This is inconvenient. (It also fails to imply that the not-taken branch will not be evaluated, since there is no lambda; this problem is also present in and and or.)

one.condNumber(v -> v.eq(of(2)), v -> of("yes"), v -> of("no"));

This alternative has two problems. First, it is always verbose. Second, because there is no self type, distinct variations must be provided for each type, which makes the name confusing (ifNumber sounds like a typecheck).

If the value must be supplied, switch can be used instead. The only reason to choose the second variant is to enforce evaluation semantics, in which case the parameters of and and or should also be lambdas.

@katcharov katcharov mentioned this pull request Jan 3, 2023
katcharov and others added 27 commits January 31, 2023 09:13
Implement arithmetic expressions (from top 50, and others)

JAVA-4803
Rename extractBsonValue

Fix access modifiers

Remove excess comments

Update docs

Fix: behaviour of get

Add notNull to API, add notNullApi test

Fix docs/annotations, tests

Fix docs, annotations, since

Fix docs

Revert external

Add missing MqlUnchecked

Fix missing null checks

Checkstyle

JAVA-4799
@katcharov katcharov merged commit ff83341 into master Jan 31, 2023
@katcharov katcharov deleted the expressions branch January 31, 2023 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants